package com.rentcars.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.rentcars.entity.CarYearcheck;
import com.rentcars.mapper.CarYearcheckMapper;
import com.rentcars.service.CarYearcheckService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author 赵瑞硕
 * @data
 */
@Service
public class CarYearcheckServiceimpl implements CarYearcheckService {
    @Autowired
    private CarYearcheckMapper carYearcheckMapper;


    @Override
    public Page queryCarInsurByPage(Map<String, Object> cond) {
        Page page=new Page();
        page.setTotal(carYearcheckMapper.getLikeCarYearcheckCount(cond));
        int pageSize=Integer.parseInt(String.valueOf(cond.get("pageSize")));
        page.setPageSize(pageSize);

        int curPageNum=Integer.parseInt(String.valueOf(cond.get("pageNum")));

        page.setPageNum((int) (page.getTotal() / pageSize + (page.getTotal() % pageSize == 0 ? 0 : 1)));
        page= PageHelper.startPage(curPageNum,pageSize);
        List list=carYearcheckMapper.getLikeCarYearcheck(cond);
        return page;
    }

    @Override
    public int deleteByPrimaryKey(String recordid) {
        return carYearcheckMapper.deleteByPrimaryKey(recordid);
    }

    @Override
    public CarYearcheck selectByPrimaryKey(String recordid) {
        return carYearcheckMapper.selectByPrimaryKey(recordid);
    }

    @Override
    public int insertSelective(CarYearcheck record) {
        return carYearcheckMapper.insertSelective(record);
    }

    @Override
    public int updateByPrimaryKeySelective(CarYearcheck record) {
        return carYearcheckMapper.updateByPrimaryKeySelective(record);
    }


    public CarYearcheckMapper getCarYearcheckMapper() {
        return carYearcheckMapper;
    }

    public void setCarYearcheckMapper(CarYearcheckMapper carYearcheckMapper) {
        this.carYearcheckMapper = carYearcheckMapper;
    }


}
